import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import { resources } from './resources'
// import LanguageDetector from 'i18next-browser-languagedetector'
// import Backend from 'i18next-http-backend'
import config from '../scripts/config'

const settings = config.getData()

i18n
  // .use(Backend)
  // .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    resources,
    fallbackLng: 'zh',
    lng: settings.lng,
    debug: false,
    interpolation: {
      escapeValue: true
    },
    // backend: {
    //   loadPath: './locales/{{lng}}.json'
    // },
    react: {
      useSuspense: false // not needed for react as it escapes by default
    }
  })

export default i18n
